package org.gy.T12.t1;

import org.junit.*;

import java.io.IOException;
import java.net.Socket;

public class StringUtilTest {
    @Test
    public void testPrintNumber(){
        StringUtil.printNumber("admin");
        StringUtil.printNumber(null);
    }

    @Test
    public void testGetMaxINDEX(){
        int index1 = StringUtil.getMaxIndex(null);
            System.out.println(index1);

        int index2 = StringUtil.getMaxIndex("admin");
            System.out.println(index2);

        //断⾔机制：预测index2的结果
        Assert.assertEquals("方法内部有bug",4,index2);
    }

    private static Socket socket;
    @Before
    public void test1(){
        System.out.println("--> test1 Before 执⾏了");
    }
    @BeforeClass
    public static void test11(){
        System.out.println("--> test11 BeforeClass 执⾏了");
//初始化Socket对象
        socket = new Socket();
    }
    @After
    public void test2(){
        System.out.println("--> test2 After 执⾏了");
    }
    @AfterClass
    public static void test22(){
        System.out.println("--> test22 AfterCalss 执⾏了");
        //关闭Socket
        try {
            socket.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
